<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>Layui</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<link rel="stylesheet" href="../layui/css/layui.css" media="all">
		
		<!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
	</head>
	<body>
		

		<form class="layui-form" action="" lay-filter="example" id="myform">
			<div class="layui-form-item" style="margin-top: 5px;">
				<label class="layui-form-label">订单编号</label>
				<div class="layui-input-block">
					<input type="text" name="orderSerial" id="orderSerial" disabled="disabled" style="width: 50%;" lay-verify="title" autocomplete="off" class="layui-input" value="">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">逾期费用</label>
				<div class="layui-input-block">
				  <input type="text" id="lastPrice" autocomplete="off" class="layui-input" style="width: 50%;" id="test1">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">损坏费用</label>
				<div class="layui-input-block">
				  <input type="text" id="brokenPrice" name="brokenPrice" class="layui-input"  style="width: 50%;" id="rentalDay" value="">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">总赔付费用</label>
				<div class="layui-input-block">
				  <input type="text" name="totalPrice" disabled="disabled" class="layui-input"  style="width: 50%; display: inline-block" id="totalPrice" value=""> 
				  <!-- <span style="display: inline-block; color: red;">*(已包含押金)每笔交易都将加上10000元押金</span> -->
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">赔损说明</label>
				<div class="layui-input-block">
				  <!-- <input type="text" name="totalPrice" class="layui-textarea"  style="width: 50%;  display: inline-block" id="totalPrice" value=""> -->
				  <!-- <span style="display: inline-block; color: red;">*(已包含押金)每笔交易都将加上10000元押金</span> -->
				  <textarea name="compDesc" class="layui-textarea" id="LAY_demo1" style="width: 50%;"></textarea>
				</div>
			</div>
						



			<div class="layui-form-item">
				<div class="layui-input-block">
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
					<button type="submit" class="layui-btn" lay-submit="" id="clickRental" lay-filter="demo1">发出赔损通知</button>
					<!-- <button type="button" id="LAY-component-form-getval">验证</button> -->
				</div>
			</div>
		</form>

		<script src="../layui/layui.js" charset="utf-8"></script>
		<!-- <script type="text/javascript" src="layui/js/jquery-1.8.3.min.js"></script> -->
		<!-- 注意：如果你直接复制所有代码到本地，上述 JS 路径需要改成你本地的 -->
		<script>





		
		</script>
		<script>
			layui.use(['form', 'layedit', 'laydate'], function() {
				var form = layui.form,
					layer = layui.layer,
					$ = layui.jquery,
					layedit = layui.layedit,
					laydate = layui.laydate;

//子窗口

				//自定义验证规则
				form.verify({
					title: function(value) {
						if (value.length < 1) {
							return '此栏不能为空噢';
						}
					}

				});
				
				$('#brokenPrice').blur(function() {
					
					
					
						let brokenPrice = $('#brokenPrice').val()
				let lastPrice = $('#lastPrice').val();
				$('#totalPrice').attr('value',parseInt(brokenPrice)+parseInt(lastPrice))
				})
				
			

				//监听提交
				form.on('submit(demo1)', function(data) {
					var value = sessionStorage.getItem("user");
					 var user = JSON.parse(value);
					console.log(data);
					
					$.post({
						url: 'http://localhost:8085/admin/modifyReturnInfo',
						data: JSON.stringify(data.field),
						dataType: "json",
						timeout: 300000,
						contentType: 'application/json; charset=UTF-8',
						success: function(result) {
							if (result) {
								layer.msg("通知成功", {
									time: 1000
								}, function() {
									 var index = parent.layer.getFrameIndex(window.name)
									 parent.layer.close(index);
									parent.location.reload();
								});
							}
						}
					});
					return false;
				});



				//表单取值
				layui.$('#LAY-component-form-getval').on('click', function() {
					var data = form.val('example');
					// alert(JSON.stringify(data));
					console.log(data);
				});

			});
		</script>
		<style>
			.layui-input {
				width: 100%
			}
			.totalPrice{
				text-align: left;
			}
		</style>
	</body>
</html>
